
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>我的订单</title>
    {include file="public/head" /}
<body>
<div class="mfc cbox headtop fl">
    <div class="sreach ret mfc ">
        <span class="fa fa-angle-left pabs-l-box fa-2x tc" style="width:1.6em;" onclick="history.go(-1)"></span>
        <p class="tc" onclick="history.go(-1)" style="font-size: 18px;">返回</p>
        <!--        <span class="pabs-r-box c-red tc" style="padding: 0 0.6em;"> 保存 </span>-->
    </div>
</div>
<div class="headtop mfc fl">
    <div class="mfc fl myorder-menu bsilk wenSwim bc-white">
        <ul>
            <li class="active" onclick="search(0,this)">全部</li>
            <li onclick="search(1,this)">已下单</li>
            <li onclick="search(23,this)">待收货</li>
            <li onclick="search(4,this)">待自提</li>
            <li onclick="search(7,this)">已完成</li>
<!--            <li onclick="search('tui',this)">退款/退单</li>-->
        </ul>
    </div>
</div>
<div class="mfc myorder-list fl" id="data">

</div>
</body>
</html>
<script>
    var data;
    // localStorage.setItem('page', 1);
    // localStorage.setItem('status', 0);
    function search(status=0,t) {
        localStorage.setItem('page', 1);
        $(t).addClass('active').siblings().removeClass('active');
        localStorage.setItem('status', status);

        data();
    }
    var status = localStorage.getItem('status');
    if(status == 0){
        $('li').eq(0).addClass('active').siblings().removeClass('active');
    }
    if(status == 1){
        $('li').eq(1).addClass('active').siblings().removeClass('active');
    }
    if(status == 23){
        $('li').eq(2).addClass('active').siblings().removeClass('active');
    }
    if(status == 4){
        $('li').eq(3).addClass('active').siblings().removeClass('active');
    }
    if(status == 'tui'){
        $('li').eq(5).addClass('active').siblings().removeClass('active');
    }

    $(function(){

        $(window).scroll(function () {
            localStorage.setItem('type', 2);
            var page = parseInt(localStorage.getItem('page'));
            var scrollTop = $(this).scrollTop();               //滚动条距离顶部的高度
            var scrollHeight = $(document).height();           //当前页面的总高度
            var windowHeight = $(this).height();               //当前可视的页面高度
            if (scrollTop + windowHeight >= scrollHeight) { //距离顶部+当前高度 >=文档总高度 即代表滑动到底部
                page += 1;
                localStorage.setItem('page', page);
                data();
            }
        })
        data = function data() {
            var page = localStorage.getItem('page');
            var status = localStorage.getItem('status');
            var type = localStorage.getItem('type');

            $.ajax({
                type: "POST", //用POST方式传输
                dataType: "html", //数据格式:JSON
                data:{page:page,status:status},
                url: "{:url('Order/ajax')}", //目标地址
                async: false,
                success: function (ret) {

                    //console.log(ret.data.data);
                    // if(ret.data.data.length === 0 && type == 1){
                    //     layer.msg('搜索结果为空');
                    // }
                    // if(ret.data.data.length === 0 && type == 2){
                    //     layer.msg('没有数据了');
                    // }



                        if(page == 1){
                            $("#data").html('');
                        }
                        $("#data").append(ret);


                }
            });
        }
        data();

    })


</script>
<style>
    .info p{ padding: 0 10px 5px;}
</style>